//内部类
/*

class OutClass {
    // 成员位置定义：未被static修饰 --->实例内部类
    public class InnerClass1 {
    }

    // 成员位置定义：被static修饰 ---> 静态内部类
    static class InnerClass2 {
    }

    public void method() {
        // 方法中也可以定义内部类 ---> 局部内部类：几乎不用
        class InnerClass5 {
        }
    }
}
*/

/*class OuterClass {
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;

    class InnerClass {
        public int data1 = 111;

        private int data4 = 4;
        public static final int data5 = 5;  //data5为常量
        private int data6 = 6;

        public void test() {
            System.out.println("InnerClass::test()");
            System.out.println(data1);//优先访问的是内部类自己的data1
            System.out.println(OuterClass.this.data1); //访问外部类的data1
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }

    public void test() {
        System.out.println("OuterClass::test()");
        System.out.println(data1); //访问外部类成员变量
        System.out.println(data2);
        System.out.println(data3);
        //外部类方法访问内部类需要先创建内部类对象来访问
        InnerClass innerClass = new InnerClass();
        System.out.println(innerClass.data1);
        System.out.println(innerClass.data4);
        System.out.println(innerClass.data6);
    }
}

public class Test3 {
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.test();
        outerClass.test();
    }
}*/


class OuterClass {
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;

    public static class InnerClass {
        public int data4 = 4;
        public static int data5 = 5;
        private int data6 = 6;
        void test() {
            System.out.println("InnerClass::test()");
            OuterClass outerClass = new OuterClass();
            //System.out.println(data1); //编译报错
            System.out.println(outerClass.data1);
            System.out.println(data2);
            //System.out.println(data3); //编译报错
            System.out.println(outerClass.data3);
            System.out.println(data5);
            System.out.println(data6);
        }
    }

    void test() {
        System.out.println("InnerClass::test()");
        OuterClass outerClass = new OuterClass();
        System.out.println(data1); //编译报错
        System.out.println(outerClass.data1);
        System.out.println(data2);
        System.out.println(data3); //编译报错
        System.out.println(outerClass.data3);
        System.out.println(InnerClass.data5);
        //System.out.println(data6);
    }
}
/*

public class Test3 {
    public static void func() {
        class AA {
            public int a = 1;
        }

        AA aa = new AA();
        System.out.println(aa.a);
    }

    public static void main(String[] args) {
        func();
    }
}*/

interface IA {
    public void test();
}
public class Test3 {
    public static void main(String[] args) {
        IA a = new IA() {
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法");
            }
        };
        a.test();
    }
}

